package com.yoomiito.app.ui.my;

import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;

import com.alibaba.fastjson.util.TypeUtils;
import com.yoomiito.app.R;
import com.yoomiito.app.base.App;
import com.yoomiito.app.model.IncomeTypeData;
import com.yoomiito.app.model.bean.TabBean;
import com.yoomiito.app.model.my.MyHistoryIncomeInfo;
import com.yoomiito.app.present.my.activity.MyMonthOrderPresenter;
import com.yoomiito.app.ui.fragment.my.MyHistoryIncomeFragment;
import com.yoomiito.app.ui.fragment.my.MyOrderBaseFragment;
import com.yoomiito.app.utils.L;
import com.yoomiito.app.utils.ResUtil;
import com.yoomiito.app.utils.SpannableUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 历史总收入
 */
public class MyHistoryIncomeActivity extends MyOrderBaseActivity<MyMonthOrderPresenter> {
    private List<IncomeTypeData> typeData = new ArrayList<>();
    @Override
    public MyMonthOrderPresenter newP() {
        return new MyMonthOrderPresenter(App.mAppConfig);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        desTv.setVisibility(View.GONE);
        titleView.setCenterText(ResUtil.getString(R.string.my_history_income));
        desTitleTv.setText("总收入");
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) topLayout.getLayoutParams();
        layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;

        typeData.add(new IncomeTypeData("导购引流","","含淘宝、京东、智能用卡订单总收入"));
        typeData.add(new IncomeTypeData("自营商品","","含送多多礼包、赠品、礼包、优品、爆品、课程订单总收入"));
        typeData.add(new IncomeTypeData("其它","","含管理津贴、市场补贴、活动奖励等其它收入"));
        mIncomeTypeView.intiView(typeData);
    }

    @Override
    protected List<MyOrderBaseFragment> getAllFragment() {
        List<MyOrderBaseFragment> list = new ArrayList<>();
        MyHistoryIncomeFragment historyIncomeFragment = new MyHistoryIncomeFragment();
        list.add(historyIncomeFragment);
        return list;
    }

    @Override
    protected List<TabBean> getTabList() {
        return null;
    }

    public void setData(MyHistoryIncomeInfo data){
        if (data != null){
            moneyTv.setText(data.getTotalIncome());
            typeData.get(0).setValue(data.getTaobaoIncome());
            typeData.get(1).setValue(data.getVipIncome());
            typeData.get(2).setValue(SpannableUtils.saleNum2(data.getOthersIncome()));
            mIncomeTypeView.updateData(typeData);
        }
    }
}
